package com.boscloud.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.boscloud.pojo.MoveLocationInfo;
import com.boscloud.pojo.PostGoodMvtResult;
import com.boscloud.pojo.RawMaterialInboundInfo;
import com.boscloud.service.MoveLocationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Slf4j
@RestController
@CrossOrigin //允许跨域
public class MoveLocationController {
    @Autowired
    private MoveLocationService MoveLocationService;
    @PostMapping("/MoveLocationInfo")//扫描条码--获取移库信息
    public List<MoveLocationInfo> getMoveLocationInfo(@RequestBody Map<String, Object> params) throws IOException {
        Map<String, String> headers = new HashMap<String, String>();
        headers.put("PORTID","ITMS004");//接口ID
        return MoveLocationService.getMoveLocationInfo(params,headers);
    }
    @PostMapping("/postMoveLocation")//移库入库
    public List<PostGoodMvtResult> PostMoveLocation(@RequestBody MoveLocationInfo MoveLocationInfo) throws IOException {
        Map<String, String> headers = new HashMap<String, String>();
        headers.put("PORTID","ITMS006");//接口ID
        //System.out.println(JSON.toJSONString(MoveLocationInfo));
        Map<String, Object> params  = JSONObject.parseObject(JSON.toJSONString(MoveLocationInfo));
        System.out.println(MoveLocationInfo);
        return MoveLocationService.postMoveLocation(params,headers);
    }
}
